<template>
    <div class="box-card">
        <h1>Login</h1>
        <el-form ref="form" :model="form">
            <el-form-item label="用户">
                <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="密码">
                <el-input v-model="form.password" type="password"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">登录</el-button>
                <span @click="setMainComponent('register')" class="register">没有账号，点击注册</span>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    import {mapMutations} from 'vuex'

    export default {
        name: "login",
        data() {
            return {
                form: {
                    name: '',
                    password: ''
                }
            }
        },
        methods: {
            onSubmit() {
                console.log('submit!');
            },
            ...mapMutations({
                setMainComponent: 'app/setMainComponent'
            })
        }
    }
</script>

<style scoped lang="less">
    .box-card{
        width: 70vw;
        padding: 12px 12px;
        position: absolute;
        right: 10vw;
        top: 20vw;
        border-radius: 2px;
        box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
        background: #FFFFFF;
    }
    .register{
        position: absolute;
        bottom: 0;
        right: 12px;
        line-height: 1;
        font-size: 9px;
        color: #409EFF;
    }
    .register:active{
        color: #e1e7ed;
    }
</style>
